// TypeScript file
module Fighter {

    /**
     * 帧动画——郭启航
     * 没有用到
     */
    export class FrameAnimation extends egret.DisplayObjectContainer {

        private constructor() {
            super();
            this.initialize();
        }
        public static instance: Fighter.FrameAnimation;
        /**Josn文件名*/
        public JosnName: string;
        /**图集名*/
        public atlasName: string;
        /**项目名*/
        public projectName: string;
        /**开始帧*/
        public StartFrame: string;
        /**循环次数*/
        public cycleIndex: number;
        /**判断是否播放完*/
        public boolPlay: boolean;
       
        public initialize() {
            this.JosnName = "Boom_json";
            this.atlasName = "Boom_png";
            this.projectName = "Boom";
            this.StartFrame = "Boom";
            this.cycleIndex = 1;
            this.boolPlay = true;

        }
        public static createAnimation(): Fighter.FrameAnimation {
            if (Fighter.FrameAnimation.instance == null) {
                Fighter.FrameAnimation.instance = new Fighter.FrameAnimation();
            }
            return Fighter.FrameAnimation.instance
        }
        /**帧动画*/
        public playAnimation(point: egret.Point, Type: string): egret.MovieClip {
            if (Type == "Gold") {
                FrameAnimation.instance.JosnName = "Gold_json";
                FrameAnimation.instance.atlasName = "Gold_png";
                FrameAnimation.instance.projectName = "Gold";
                FrameAnimation.instance.StartFrame = "Gold";
                FrameAnimation.instance.cycleIndex = -1;
            }
            if(Type=="Slay")
            {
                FrameAnimation.instance.JosnName = "bolt_json";
                FrameAnimation.instance.atlasName = "bolt_png";
                FrameAnimation.instance.projectName = "bolt";
                FrameAnimation.instance.StartFrame = "bolt";
                FrameAnimation.instance.cycleIndex = 1;
            }
            if(Type=="Shield")
            {
                 FrameAnimation.instance.JosnName = "Shield_json";
                FrameAnimation.instance.atlasName = "Shield_png";
                FrameAnimation.instance.projectName = "Shield";
                FrameAnimation.instance.StartFrame = "Shield";
                FrameAnimation.instance.cycleIndex = -1;
            }
            this.boolPlay = false;
            var texture2mc = RES.getRes(this.atlasName);
            var data2mc = RES.getRes(this.JosnName);
            let mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data2mc, texture2mc);
            let mc: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData(this.projectName));
            mc.gotoAndPlay(this.StartFrame, this.cycleIndex);//"A" : Boom -1 ： 循环播放				
            mc.x = point.x - 70;//帧动画位置
            mc.y = point.y - 50;
            return mc;
        }

    }
}